﻿
// FileManagerDlg.h: 头文件
//

#pragma once

#include "FileManager.h"

#define DISK_MAX_NUM    2

// CFileManagerDlg 对话框
class CFileManagerDlg : public CDialogEx, public IFileMgrUI
{
// 构造
public:
	CFileManagerDlg(CWnd* pParent = nullptr);	// 标准构造函数

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_FILEMANAGER_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

public:
    CEdit       m_editWorkPath;
    CEdit       m_editDiskInfo;
    CTreeCtrl   m_treeLocal;
    CTreeCtrl   m_treeDevice;
    CComboBox   m_cmbSerial;
    CComboBox   m_cmbBaudRate;
    CButton     m_btnDLoad;
    CButton     m_btnSerial;

private:
    CString     m_strRootPath;
    CString     m_strSerial;
    HTREEITEM   m_hTreeRoot;       //句柄 CTreeCtrl的根结点
    FileMgrEngine m_hFileMgr;

    UINT        m_uDiskTotal[DISK_MAX_NUM];
    UINT        m_uDiskFree[DISK_MAX_NUM];

// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

public:
    bool EnumSerialPort();
    CString GetLocalPath(HTREEITEM hItem);
    CString GetDevicePath(HTREEITEM hItem);
    bool LoadDirFiles(HTREEITEM hParent, CString strPath);
    //bool LoadFileList();
    bool InsertDevFile(HTREEITEM hParent, CString strPath);
    void DelAllChildOfItem(HTREEITEM hItem);

    virtual void OnInsert(const char* strPath, bool bIsDir);
    virtual void OnDiskInfo(int iDiskId, uint32_t uTotal, uint32_t uFreex);

    afx_msg void OnClose();
    afx_msg void OnTimer(UINT_PTR nIDEvent);
    afx_msg void OnBnClickedBtnLoadPath();
    afx_msg void OnBnClickedBtnConnect();
    afx_msg void OnBnClickedBtnGetFiles();
    afx_msg void OnBnClickedBtnDeleteFile();
    afx_msg void OnBnClickedBtnDownload();
    afx_msg void OnClickedBtnSerialOpen();
    afx_msg void OnBnClickedBtnDiskFormat();
};
